package com.cooge.jiexi;

import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Locale;

import com.alibaba.fastjson.JSONObject;


public class huashulive {
//http://www.wasu.cn/Play/show/id/1608158
public static void main(String[] args) throws Exception {
				String link = "http://clientapi.wasu.cn/Phone/liveinfo/id/2971428";
				String source = NetUtil.getHtml(link);
				source = source.substring(source.indexOf("{"), source.lastIndexOf("}")+1);
				JSONObject jso = JSONObject.parseObject(source);
				String playurl = jso.getString("url");
				System.out.println(playurl);
				System.out.println(getPlayUrl(new URL(playurl),playurl));
		

	}
	
public static String getPlayUrl(URL localURL,String url) throws Exception{
	System.out.println(localURL.getHost());
	String paramString2 = "liveWASU12#$56&*";
	String str3 = getDateCompleteStr(System.currentTimeMillis());
	URL url_ = new URL(url);
	 String str4 = url.substring(url.indexOf(url_.getHost()) + url_.getHost().length());
	 paramString2 = paramString2 + str3 + str4;
	 String playurl = "http://"+localURL.getHost() + "/" + str3 + "/" + NetUtil.md5(paramString2)+str4;
	return playurl;
}

 public static String getDateCompleteStr(long paramLong)
  {
    SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat("", Locale.SIMPLIFIED_CHINESE);
    localSimpleDateFormat.applyPattern("yyyyMMddHHmm");
    return localSimpleDateFormat.format(Long.valueOf(paramLong));
  }

}
